// pages/aboutUs/aboutUs.js
var app = getApp();
var util = require("../../utils/util.js");
var config = require("../../utils/config.js");
var WxParse = require("../../wxParse/wxParse.js");
Page({

  /**
   * 页面的初始数据
   */
  data: {
    screen: app.data.screen,
    hidden: 2,
    message: []
  },
  onLoad(options) {

  },
  /**
   * 生命周期函数--监听页面显示
   */
  onShow () {
    var that = this;
    console.log(that.data.message)
    if (that.data.message.length <= 0) {
      that.request();
    }
    // 查看是否授权
    wx.getSetting({
      success(res) {
        if (res.authSetting['scope.userInfo']) {
        } else {
          wx.navigateTo({
            url: '/pages/login/login',
          });
        }
      }
    })
  },
  //  网络请求
  request() {
    util.getOpenID((e) => {
      var parameters = {
        openid: e.openid
      }
      util.postRequest(config.aboutUs, parameters, (res) => {
        console.log(res)
        if (res.code == 200) {
          var article = res.data.content
          WxParse.wxParse('article', 'html', article, this, 5);
          this.setData({
            hidden: 1,
            message: res.data,
          })
        } else if (res.code == 201) {
          wx.showToast({ title: '请求失败!', icon: 'none' })
        }
      }, () => {
        //请求失败
      }, () => {
        //请求完成
      }, false);
    }, false);
  }

})

